package com.neusoft.neuiotms.dcam.fixed.excel;

import java.util.Map;

import com.neusoft.neuiotms.dcam.constant.DCAMConsts;

import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl;

public class AssetMapImportHanlder extends ExcelDataHandlerDefaultImpl<Map<String, Object>> {
    @Override
    public void setMapValue(final Map<String, Object> map, final String originKey, final Object value) {
        map.put(this.getRealKey(originKey), value != null ? value.toString() : null);
    }

    private String getRealKey(final String originKey) {
        if (originKey.equals(DCAMConsts.ASSET_NAME)) {
            return DCAMConsts.ASSET_NAME_KEY;
        }
        if (originKey.equals(DCAMConsts.ASSET_CODE)) {
            return DCAMConsts.ASSET_CODE_KEY;
        }
        if (originKey.equals(DCAMConsts.ASSET_CONTRACTITEM)) {
            return DCAMConsts.ASSET_CONTRACT_KEY;
        }
        if (originKey.equals(DCAMConsts.ASSET_LOCATION)) {
            return DCAMConsts.ASSET_LOCATION_KEY;
        }
        if (originKey.contains(DCAMConsts.DICTIONARY_SPLITOR)) {
            final String[] str = originKey.split(DCAMConsts.DICTIONARY_SPLITOR);
            return str[1];
        }
        return originKey;
    }
}
